package jus.aoo.annuaire;
import jus.aoo.annuaire.Interface;
public class Personne implements Comparable<Personne> {
	
	public static enum Civilite{
		INCONNU,MELLE("Mademoiselle"),MME("Madame"),MR("Monsieur");
		private String reptext;
		
		Civilite(){}

		Civilite(String reptext){
			this.reptext = reptext;
		}
		/*
		@Override
		public String toString() {
			try {
				return reptext;
			} catch (NullPointerException e) {
				return super.toString();
			}
			
		}
		*/
		public String getReptext(){
			return reptext;
		}
		
	}
	
	private String nom;
	private String prenom;
	private Civilite civilite;
	
		
	public Personne(String nom, String prenom) {
		this.nom = nom;
		this.prenom = prenom;
	}
	
	public Personne(Civilite civilite,String nom, String prenom) {
		this.nom = nom;
		this.prenom = prenom;
		this.civilite = civilite;
	}
	
	public Personne(int civilite,String nom, String prenom) {
		this.nom = nom;
		this.prenom = prenom;
		if(civilite == 0)
			{this.civilite = Civilite.INCONNU;}else if(civilite==2)
			{this.civilite = Civilite.MELLE;}else if(civilite==3)
			{this.civilite = Civilite.MR;}
	}
	
	
	
	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof Personne)){return false;}
		Personne p=(Personne)obj;
		return (p.getNom()==this.getNom()&&p.getPrenom()==this.getPrenom());
	}
	
	@Override
	public int hashCode() {
		return this.getNom().hashCode()+this.getNom().hashCode();
	}
	
	@Override
	public String toString() {
		return this.civilite+" "+this.nom+" "+this.prenom;
	}

	public String getNom() {
		return nom;
	}
	public void setNom(String nom) {
		this.nom = nom;
	}
	public String getPrenom() {
		return prenom;
	}
	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}
	public Civilite getCivilite() {
		return civilite;
	}
	public void setCivilite(Civilite civilite) {
		this.civilite = civilite;
	}
	
	@Override
	public int compareTo(Personne o) {
		if(o.getNom()==this.nom&&o.getPrenom()==this.prenom)
			return 0;
		else
			return -1;
	}
	
	
	
	
}
